package com.source.diyjuc;

import java.util.concurrent.*;

/**
 * @Author wengqy
 * @Date 2021/1/18
 */
public class MainSourcetst {
    public static void main(String[] args) {


        ExecutorService threadPool = new ThreadPoolExecutor(
                2,
                5,
                2L,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardPolicy());
                // 模拟有6,7,8,9,10个顾客过来银行办理业务，观察结果情况
                // 最大容量为：maximumPoolSize + workQueue = 最大容量数 8

        try {
            for (int i = 1; i <= 200; i++) {
                threadPool.execute(()->{
                    System.out.println(Thread.currentThread().getName()+" 办 理业务"); });
            }
        }catch (Exception e){
            System.out.println("异常信息打印。。。。。。。。。。。。");
        }finally {
            threadPool.shutdown();
        }





    }
}
